package cn.incoder.moyun.controller;

import cn.incoder.moyun.pojo.system.User;
import cn.incoder.moyun.service.system.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/save")
    public boolean save(@RequestBody User user) {
        return userService.save(user);
    }

    @GetMapping("/get")
    public List<User> getAll() {
        return userService.list();
    }
    @GetMapping("/getById")
    public User getById(@RequestParam Long id) {
        return userService.getById(id);
    }
    @PostMapping("/creatUser")
    public boolean updataUser(@RequestBody User user) {
        return userService.creatUser(user);
    }
}
